// T2
// O(n log n) 100pts

#include <bits/stdc++.h>
using namespace std;

struct car
{
    int x0, v0, a;
};

struct range
{
    int l, r;
};

const int N = 1e5+5;
vector<int> cars[N]; // sensors able to detect this car
vector<range> carRange;
// vector<int> sensors[N]; // cars able to be detected by this sensor
int pos[N]; // sersors' pos
int n, m, L, v;

bool operator<(range a, range b)
{
    return a.r==b.r ? a.l<b.l : a.r<b.r;
}

double getV(car c, int p) // v of the car at x=p
{
    if (c.x0 > p)
        return 0;
    if (c.a > 0)
        return sqrt(c.v0*c.v0 + 2*c.a*(p-c.x0));
    else if (c.a == 0)
        return c.v0;
    else
    {
        double t = -c.v0*1.0/c.a;
        double x_stop = c.v0*t + c.a*t*t/2.0;
        if (x_stop <= p-c.x0)
            return 0;
        else
            return sqrt(c.v0*c.v0 + 2*c.a*(p-c.x0));
    }
}

bool exceed(car c, int p, int v)
{
    double t = -c.v0*1.0/c.a;
    double x_stop = c.v0*t + c.a*t*t/2.0;
    if (x_stop <= p-c.x0)
        return false;
    else
        return c.v0*c.v0 + 2*c.a*(p-c.x0) > v*v;
}

void solve()
{
    for (int i=0; i<n; i++)
        cars[i] = vector<int>();
    carRange = vector<range>();
    scanf("%d%d%d%d", &n, &m, &L, &v);
    vector<car> tmp;
    for (int i=0; i<n; i++)
    {
        int d, v, a;
        scanf("%d%d%d", &d, &v, &a);
        tmp.push_back({d, v, a});
    }
    for (int i=0; i<m; i++)
        scanf("%d", &pos[i]);
    sort(pos, pos+m);

    for (int i=0; i<n; i++)
    {
        int entry = lower_bound(pos, pos+m, tmp[i].x0) - pos;
        if (entry == m)
            continue;
        if (tmp[i].a == 0)
        {
            if (tmp[i].v0 > v)
                carRange.push_back({entry, m-1});
        }
        else if (tmp[i].a>0)
        {
            if (getV(tmp[i], pos[m-1]) <= v)
                continue;

            int l=entry, r=m-1;
            int mid;
            while (l<r)
            {
                mid = (l+r)/2;
                if (getV(tmp[i], pos[mid]) <= v)
                    l = mid + 1;
                else
                    r = mid;
            }
            carRange.push_back({l, m-1});
        }
        else
        {
            if (!exceed(tmp[i], pos[entry], v))
                continue;
            int l=entry, r=m-1;
            int mid;
            while (l<r)
            {
                mid = (l+r)/2 + (r-l)%2;
                if (exceed(tmp[i], pos[mid], v))
                    l = mid;
                else
                    r = mid-1;
            }
            carRange.push_back({entry, l});
        }
    }

    sort(carRange.begin(), carRange.end());

    queue<range> q;
    for_each(carRange.begin(), carRange.end(), [&](range r){q.push(r);});
    // for_each(carRange.begin(), carRange.end(), [](range r){printf("%d-%d\n", r.l, r.r);});
    int sensorCnt = 0;
    int lastSen = -1;
    while (!q.empty())
    {
        lastSen = q.front().r;
        sensorCnt++;
        // printf("Sensor %d @ %d activated.\n", lastSen, pos[lastSen]);
        while (!q.empty() && q.front().l<=lastSen)
            q.pop();
    }

    printf("%d %d\n", carRange.size(), m-sensorCnt);
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    int t;
    scanf("%d", &t);
    while (t--)
        solve();

    return 0;
}